<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>饼图</title>
</head>
<body>

<div id="chart1" style="width:600px;height:380px">

</div>
</body>
<script src="../node_modules/echarts/dist/echarts.js"></script>
<script src="../node_modules/mockjs/dist/mock.js"></script>
<script>

     var source = Mock.mock({
         'list|4':[{
             'name':function () {
                 return '广告'+Mock.Random.increment()
             },
             value:'@natural(200,500)'
         }]
     });  //  Mock.mock(rules)


    // console.log(source);

    var chart = echarts.init(document.getElementById("chart1"));

     var  option = {
        title: {
            text: '某站点用户访问来源'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            top:'5%',
            left: 'center',
        },
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: '50%',
                data:source.list,
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };

    chart.setOption(option);


</script>


</html>